package cz.possoft.serializable.dama.figurky;

import cz.possoft.generic.utils.GenericUtils;
import cz.possoft.messages.PropertiesManager;
import cz.possoft.messages.Text;
import cz.possoft.serializable.dama.game.DamaPole;

/**
 * Kamen (pesec) u hry dama
 * 
 * @author mara
 */
public class DamaKamen extends DamaFigurka {
	
	public static final long serialVersionUID = 5629499;
    
    public DamaKamen() {        
    }
    
    /** Creates a new instance of DamaKamen */
    public DamaKamen(int x,int y,int color,DamaPole sachovnice) {
        setX(x);
        setY(y);
        setColor(color);
        setSachovnice(sachovnice);
        setMarkedForPlay(false);
    }
    
    public String getFigurkaName() {
        return PropertiesManager.getInstance().getMessageForKey(Text.KAMEN);
    }
    
    public boolean muzeTahnout(int xCil,int yCil) {
        if ((xCil<0)||(xCil>7)||(yCil<0)||(yCil>7)) return false;
        
        if (getColor() == GenericUtils.COLOR_WHITE) {
            if (((GenericUtils.abs(xCil - getX()) == 1)) && (yCil - getY() == -1) && (getSachovnice().getFigurka(xCil, yCil).getColor() == GenericUtils.COLOR_NEUTRAL)) return true;
            
            //if ((GenericUtils.abs(getX() - xCil) == 1) && (yCil - getY() == -1) && (getSachovnice().getFigurka(xCil, yCil).getColor() == 1)) return true;
        }
        if (getColor() == GenericUtils.COLOR_BLACK) {              
            if (((GenericUtils.abs(xCil - getX()) == 1)) && (yCil - getY() == 1) && (getSachovnice().getFigurka(xCil, yCil).getColor() == 0)) return true;
            
            //if ((GenericUtils.abs(getX() - xCil) == 1) && (yCil - getY() == 1) && (getSachovnice().getFigurka(xCil, yCil).getColor() == 2)) return true;
        }                                        
        return false;        
    }
    
}
